#include "TokenBlock.h"
#include "Token.h"
#include "VarTable.h"
#include "Error.h"
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
	if (argc == 1)
		Context::init(&cin);
	else
	{
		ifstream* fin = new ifstream(argv[1]);
		Context::init(fin, false);
	}
	VarTable::init();
	TokenBlock tb;
	do
	{
		try
		{
			tb.run(true);
		}
		catch (ErrorExit& ee)
		{
			//(ctx -> stdOut()) << endl;
			break;
		}
		catch (Error& e)
		{
			e.showMsg();
			//Context* ctx = Context::getInstance();
			//ctx -> resetIndent();
		}
	} while (argc == 1);
	VarTable::del();
	Context::del();
	return 0;
}

